package com.chen.filters;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebInitParam;
import java.io.IOException;

@WebFilter(
        urlPatterns = "/*",
        servletNames = "servletA",
        filterName = "filter3",
        initParams = {
                @WebInitParam(name = "key", value = "valueA", description = "第一个值") // 设置FilterConfig对象中初始化参数
        }

)
public class Filter3 implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("init 方法执行了");
        System.out.println(filterConfig.getInitParameter("key"));
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println(" filter3 放行前");
        filterChain.doFilter(servletRequest, servletResponse);
        System.out.println(" filter3 放行后");
    }
}
